import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state:{
        // 存储token
        Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization'): '',
        userInfo:localStorage.getItem('userInfo') ? localStorage.getItem('userInfo'): '',
        sqlstr:''
    },

    mutations: {
        // 修改token，并将token存入localStorage
        changeLogin (state, user){
            state.Authorization = user.Authorization;
            console.log(user);
            localStorage.setItem('Authorization', user.Authorization);
        },
        changeUserInfo (state, user){
            state.userInfo = user.userInfo;
            console.log(user,'userInfo');
            localStorage.setItem('userInfo', user.userInfo);
        },
    }
})

export default store